<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org/">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <h1>哈哈哈-大汽车 1元秒杀</h1>
    <form id="msform" th:action="@{/doseckill}" enctype="application/x-www-form-urlencoded">
        <input type="hidden" id="prodid" name="prodid" value="0101">
        <button type="button" id="miaosha_btn" name="seckill_btn">秒杀点我</button>
    </form>
    <script th:src="@{/jquery-3.4.1.min.js}"></script>
    <script>
        $(function () {
            var url = $("#msform").attr("action");
            $("#miaosha_btn").click(function(){
                $.post(url,$("#msform").serialize(),function(data){
                    if(data==1){
                        alert("系统错误");
                    }else if(data==2){
                        alert("秒杀还没有开始");
                    }else if(data==3){
                        alert("已经秒杀成功，请勿重复秒杀");
                    }else if(data==4){
                        alert("秒杀已结束");
                    }else if(data==5){
                        alert("秒杀失败了");
                    }else if(data==0){
                        alert("秒杀成功")
                    }
                })
            })
        })
    </script>
</body>
</html>